﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.ServiceModel;
using CNShapes;

namespace CNNetworking
{
    /// <summary>
    /// This is the callback-interface used to send messages back to clients
    /// from the server. This includes connection information such as heartbeats
    /// and which clients are available, as well as updates to drawing data itself.
    /// </summary>
    public interface IServerToClient
    {
        /// <summary>
        /// Called by the server to notify clients that it is disconnecting.
        /// </summary>
        [OperationContract(IsOneWay = true)]
        void onDisconnected();

        /// <summary>
        /// Sends a heartbeat from the server to the client.
        /// </summary>
        [OperationContract(IsOneWay = true)]
        void onHeartbeat();

        /// <summary>
        /// Called when the list of clients connected to the same session changes.
        /// Names are in the format "FirstName LastName"
        /// </summary>
        [OperationContract(IsOneWay=true)]
        void onClientListUpdated(IList<string> clientNames);

        /// <summary>
        /// Requests that the client tell us about the server connection list that it holds.
        /// </summary>
        [OperationContract(IsOneWay = true)]
        void requestServerConnectionList();

        /// <summary>
        /// Called by the server to share a new set of connection settings with clients.
        /// These may not be all the connection settings in the system. Mostly they will 
        /// just be the set of connection settings from one client.
        /// </summary>
        [OperationContract(IsOneWay=true)]
        void onNewServerConnectionList(IList<ConnectionSettings> connectionSettings);

        /// <summary>
        /// Called by the server to start a new session.
        /// </summary>
        [OperationContract(IsOneWay = true)]
        void onNewSession(Guid sessionID);

        /// <summary>
        /// Called by the server to add a new page to a session.
        /// </summary>
        [OperationContract(IsOneWay = true)]
        void onNewPage(Guid sessionID, Guid pageID);

        /// <summary>
        /// Called by the server to change the active page in the session.
        /// </summary>
        [OperationContract(IsOneWay = true)]
        void onActivePageChanged(Guid sessionID, Guid pageID);

        /// <summary>
        /// Called by the server to add a shape to the specified page in the session.
        /// </summary>
        [OperationContract(IsOneWay = true)]
        [NetDataContract]
        void onNewShape(Guid sessionID, Guid pageID, Shape shape);

        /// <summary>
        /// Called by the server to update a shape for the specified page in the session.
        /// </summary>
        [OperationContract(IsOneWay = true)]
        [NetDataContract]
        void onUpdatedShape(Guid sessionID, Guid pageID, Shape shape);

    }
}
